<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>计数器</h2>
    <p id="counter">0</p>
    <button onclick="decrement()">减少</button>
    <button onclick="increment()">增加</button>
    

    <script>
        let count = 0;

        function increment() {
            count++;
            document.getElementById('counter').innerText = count;
        }

        function decrement() {
            count--;
            document.getElementById('counter').innerText = count;
        }
    </script>
</body>
</html>